<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue</title>
  </head>
  <body>
  <script src="https://unpkg.com/vue@2.6.14/dist/vue.js"></script>
    <div id="app">
        <input v-focus/>
    </div>
    <script>
        Vue.directive('focus',{
            //当被绑定的元素插入父节点的时候调用
            inserted(el){
                el.focus();
            }
        });
        var vm = new Vue({
            el:'#app',
        })
    </script>
  </body>
</html>
